#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>

using namespace std;

void PrintPending()
{ 
    sigset_t set;
    sigemptyset(&set);
    sigpending(&set);

    for(int i=31;i>=1;i--)
    {
        if(sigismember(&set,i)) cout<<1;
        else cout<<0;
    }
    cout<<"\n";
}

void handler(int signo)
{
    cout<<"get a sig: "<<signo<<endl; 
    while(true)
    { 
        PrintPending();
        sleep(1);
    }
    
}

int main()
{
    struct sigaction act,oact;
    act.sa_handler=handler;
    sigaddset(&act.sa_mask,3);
    sigaddset(&act.sa_mask,4);

    sigaction(2,&act,&oact);
    while (true)
    {
        cout << "i am a process: " << getpid() << endl;

        sleep(1);
    }


    return 0;
}